mem_sharing: fix race condition of nominate and unshare
authorTim Deegan <Tim.Deegan@citrix.com>
Thu, 6 Jan 2011 16:58:48 +0000 (16:58 +0000)
committerTim Deegan <Tim.Deegan@citrix.com>
Thu, 6 Jan 2011 16:58:48 +0000 (16:58 +0000)
commit6b43e7533c3cb120765bf0693a3f3fc13ed168b2
treebba2f0910edc3fce54cb046a80a763e18f97998c
parent7e600e448519040d4857d291ddc8f34277d2c67e
mem_sharing: fix race condition of nominate and unshare

(1) When updating/checking p2m type for mem_sharing, we must hold shr_lock
(2) For nominate operation, if the page is already nominated, return the
    handle from page_info->shr_handle
(3) For unshare operation, it is possible that multiple users unshare a
    page via hvm_hap_nested_page_fault() at the same time. If the page
    is already un-shared by someone else, simply return success.

Signed-off-by: Jui-Hao Chiang <juihaochiang@gmail.com>
Signed-off-by: Han-Lin Li <Han-Lin.Li@itri.org.tw>
Acked-by: Tim Deegan <Tim.Deegan@citrix.com>
xen/arch/x86/mm/mem_sharing.c